
import '../model/travel_tab_model.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;

const TRAVEL_TAB_URL = 'http://www.devio.org/io/flutter_app/json/travel_page.json';
class TraveltabDao {
  static Future<TravelTabModel> fetch() async{
    var url = Uri.parse(TRAVEL_TAB_URL);
    final response = await http.get(url);
    if(response.statusCode == 200){
      Utf8Decoder utf8decoder = Utf8Decoder();
      final result = json.decode(utf8decoder.convert(response.bodyBytes));
      return TravelTabModel.fromJson(result);
    }else {
      throw Exception('flutter_app/json/home_page.json 接口异常');
    }
  }
}